package day11.console.impl;

import day11.packet.request.LoginRequestPacket;
import day11.util.LoginUtil;
import day11.util.session.SessionUtil;
import day11.console.ConsoleCommand;
import io.netty.channel.Channel;

import java.util.Scanner;

/**
 * @author chenshijie
 * @date 2024/1/1 14:33
 */

public class LogoutConsoleCommand implements ConsoleCommand {
    @Override
    public void exec(Scanner sc, Channel channel) {
        System.out.println("退出登录中...");
        LoginRequestPacket loginRequestPacket = new LoginRequestPacket();
        loginRequestPacket.setLoginStatus(LoginUtil.LOGOUT);
        channel.writeAndFlush(loginRequestPacket);
        SessionUtil.unBindSession(channel);
        System.out.println("已退出登录！");

    }
}
